String clazzTpl({nameCode, svgCase}) => """
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/svg.dart';

/// 请叫我code哥
/// Generates Dart code
enum IconFontName {
  ///自动生成，误自己添加
$nameCode
}

enum AnimType {
  ///自动生成，误自己添加
  ///没有动画
  none,
  ///正向
  forward,
  ///反向
  reverse,
  ///正向重复
  repeat,
  ///反向重复
  reverseRepeat,
}

typedef OnStart = void Function();
typedef OnEnd = void Function();

/// 请叫我code哥
/// Generates Dart code
class IconFont extends StatelessWidget {
  ///自动生成，误自己添加
  IconFont(
    this.name, {
    Key key,
    this.size = 14,
    this.color,
    this.colors,
    this.curve = Curves.ease,
    this.paintingStyle = PaintingStyle.fill,
    this.strokeWidth = 1,
    this.duration = const Duration(seconds: 3),
    this.animType = AnimType.forward,
    this.loop  = 1,
    this.onStart,
    this.onEnd,
  }) : super(key: key);
  final IconFontName name;
  final Color color;
  final List<Color> colors;
  final double size;
  /// 以下字段兼容切换，无实际意义
  final Curve curve;
  final PaintingStyle paintingStyle;
  final double strokeWidth;
  final Duration duration;
  final AnimType animType;
  final int loop;
  final OnStart onStart;
  final OnEnd onEnd;

  String getColor(
      int arrayIndex, Color color, List<Color> colors, String defaultColor) {
    if (color != null) {
      return color.toHex();
    }
    if (colors != null && colors.isNotEmpty && colors.length > arrayIndex) {
      return colors.elementAt(arrayIndex).toHex();
    }
    return defaultColor;
  }

  String getSvgXml() {
    String svgXml;
    switch (name) {
$svgCase
    }
    return svgXml;
  }

  @override
  Widget build(BuildContext context) {
    String svgXml = getSvgXml();
    if (svgXml == null) {
      return Container();
    }
    return SvgPicture.string(svgXml, width: this.size, height: this.size);
  }
}

extension HexColor on Color {
  /// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#".
  static Color fromHex(String hexString) {
    final buffer = StringBuffer();
    if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
    buffer.write(hexString.replaceFirst('#', ''));
    return Color(int.parse(buffer.toString(), radix: 16));
  }

  /// Prefixes a hash sign if [leadingHashSign] is set to `true` (default is `true`).
  String toHex({bool leadingHashSign = true}) => '\${leadingHashSign ? '#' : ''}'
      '\${alpha.toRadixString(16).padLeft(2, '0')}'
      '\${red.toRadixString(16).padLeft(2, '0')}'
      '\${green.toRadixString(16).padLeft(2, '0')}'
      '\${blue.toRadixString(16).padLeft(2, '0')}';
}
""";
